home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: registerTrans.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:02 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "latch.h"
- #include "bf.h"
- #include "volume.h"
- #include "trans.h"
- #include "trans_intfuncs.h"
- #include "trans_extfuncs.h"
- #include "thread_globals.h"
- #include "trans_globals.h"
-
-
- /*
- * This function associates a thread with a transaction. If the
- * thread will be writing the log, then it must aquire the log
- * semaphore by passing in TRUE to getLogSemaphore.
- */
-
-
- TRANSREC
- *registerTrans (
-
- TID tid,
- BOOL getLogSemaphore
- )
- {
-
- register TRANSREC *transRec;
-
-
- TRPRINT(TR_TRANS, TR_LEVEL_1, ("tid:%x", tid));
-
- /*
- * Get a pointer to the bucket
- */
- if ((transRec = findTransRec(tid)) == NULL) {
-
- return(NULL);
- }
-
- /*
- * Deal with transactions which are not active
- */
- if (transRec->transState == T_QUIESCE) {
- if (transRec->intent == T_ABORT) {
- SM_ERROR(TYPE_USER, esmBADTRANSID);
- return(NULL);
- }
-
- /*
- * this should never happen, no new messages should be coming
- * in for a transaction that is committing
- */
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
- if (transRec->transState != T_ACTIVE ) {
- SM_ERROR(TYPE_USER, esmBADTRANSID);
- return(NULL);
- }
-
- /*
- * hang the transaction off the transaction block
- */
- listEnq( &(transRec->threadList), &(Active->transList) );
-
- /*
- * increment the number of threads active for transaction
- */
- transRec->threadCount++;
- TRPRINT(TR_TRANS, TR_LEVEL_2, ("threadCount:%d", transRec->threadCount));
-
- if (getLogSemaphore) {
- if (waitSemaphore(&(transRec->logSemaphore))) {
- SM_ERROR(TYPE_CRASH, esmINTERNAL);
- }
- }
-
- /*
- * fill in the transaction pointer
- */
- Active->transRec = (char *) transRec;
-
- /*
- * return the transaction record
- */
- return(transRec);
- }
-